package com.aaa.controller;

import com.aaa.entity.MyReturn;
import com.aaa.entity.PageSort;
import com.aaa.entity.TblTester;
import com.aaa.service.TblTesterService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;



/**
 * @Author:
 * @Description TblTesterControler
 * @Date
 * @Modifiel
 */
@Controller
@RequestMapping("tblTester")
public class TblTesterController extends BaseController{
    MyReturn myReturn = new MyReturn();
    @Autowired
    private TblTesterService tblTesterService;

    @RequestMapping("tester.do")
    private String Pages() {
        return "tester";
    }

    /**
     *
     * @param pageSort
     * @return MyReturn
     *  查询  模糊查询
     */
    @ResponseBody
    @RequestMapping("selectTblTester.do")
    public MyReturn selectTblTester(PageSort pageSort){
        Page page = tblTesterService.selectTblTester(pageSort);
        //获取查询结果
        myReturn.setData(page.getResult());
        //获取总条数
        myReturn.setCount(page.getTotal());

        return super.getSuccessResult(myReturn);
    }

    /**
     *
     * @param tblTester
     * @return MyReturn
     *  添加
     */
    @ResponseBody
    @RequestMapping("insertTblTester.do")
    public MyReturn insertTblTester(TblTester tblTester){
        System.out.println(tblTester.getCreateTime());
        if (tblTesterService.insertTblTester(tblTester)){
            return super.getSuccessResult(myReturn);
        }
        return super.getFailResult(myReturn);
    }

    /**
     *
     * @param id
     * @return MyReturn
     *  删除
     */
    @ResponseBody
    @RequestMapping("deleteTblTester.do")
    public MyReturn deleteTblTester(String id){
        if (tblTesterService.deleteTblTester(id)){
            return super.getSuccessResult(myReturn);
        }
        return super.getFailResult(myReturn);
    }

    /**
     *
     * @param tblTester
     * @return MyReturn
     *  修改
     */
    @ResponseBody
    @RequestMapping("updateTblTester.do")
    public MyReturn updateTblTester(TblTester tblTester){
        if (tblTesterService.updateTblTester(tblTester)){
            return super.getSuccessResult(myReturn);
        }
        return super.getFailResult(myReturn);
    }
}
